
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.WindowConstants;
import javax.swing.border.Border;


@SuppressWarnings("serial")
public class ItemCard extends JFrame {
	final static JLabel common_color = new JLabel("Couleur :");
	final static JLabel borderone_color = new JLabel("Bordure :");
	final static JLabel bordertwo_color = new JLabel("Contour :");
	
	JTextField field_num = new JTextField() {
		public void setBorder(Border border) { /*no border */ }
	};
	JTextField field_name = new JTextField(){
		public void setBorder(Border border) { /*no border */ }
	};
	
	JFrame test = new JFrame("Card Item");
	JPanel card = new JPanel(new GridLayout(5,3,0,10));
	
	Color common;
	Color borderone;
	Color bordertwo;
	
	
	public ItemCard(ItemBoxed b){
		field_num.setText(b.getItemNum());
		field_name.setText(b.getName());
		//field_color.setText(b.hexToColor(0));
		//field_borderone.setText(b.hexToColor(1));
		//field_bordertwo.setText(b.hexToColor(2));
		common = b.getColor(0);
		borderone = b.getColor(1);
		bordertwo = b.getColor(2);
		Dimension d = new Dimension(400,300);
		card.setPreferredSize(d);
		init(b);
	}
	
	public void init(ItemBoxed b){
		field_num.setEditable(false);
		field_num.setFont(new Font(field_num.getFont().getFontName(), Font.BOLD, 36));
		field_num.setBackground(UIManager.getColor("Panel.background"));
		card.add(field_num);
		field_name.setEditable(false);
		field_name.setFont(new Font(field_num.getFont().getFontName(), Font.BOLD, 36));
		field_name.setBackground(UIManager.getColor("Panel.background"));
		card.add(field_name);
		card.add(common_color);
		//card.add(field_color);
		card.add(new ComponentColor(common));
		card.add(borderone_color);
		//card.add(field_borderone);
		card.add(new ComponentColor(borderone));
		card.add(bordertwo_color);
		card.add(new ComponentColor(bordertwo));
		//card.remove(5);
		//card.add(new ComponentColor(new Color(0,0,255)),5);
		test.add(card);
		test.setLocation(450, 0);
		test.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
		test.pack();
		test.setVisible(true);

	}
}

